﻿using System;
using System.Linq;
using WebExam.DataEntities;

namespace WebExam.DataProvider
{
    public interface ITXRepository
    {
        /// <summary>
        /// 获取题型信息
        /// </summary>
        /// <param name="start">开始位置</param>
        /// <param name="takeSize">获取条数</param>
        IQueryable<TX> GetAll(int start, int takeSize);

        /// <summary>
        /// 获取指定试卷下的题型信息
        /// </summary>
        /// <param name="examId">试卷Id</param>
        /// <param name="start">开始位置</param>
        /// <param name="takeSize">获取条数</param>
        IQueryable<TX> GetAll(int examId,int start, int takeSize);

        /// <summary>
        /// 获取题型信息
        /// </summary>
        /// <param name="txId">题型Id</param>
        TX Get(int txId);

        /// <summary>
        /// 添加题型信息
        /// </summary>
        /// <param name="tx">题型对象</param>
        TX Add(TX tx);

        /// <summary>
        /// 更新题型信息
        /// </summary>
        /// <param name="txId">题型Id</param>
        /// <param name="update">包含更新操作的方法</param>
        TX Update(int txId, Action<TX> update);

        /// <summary>
        /// 删除题型信息
        /// </summary>
        /// <param name="txId">题型Id</param>
        bool Delete(int txId);

        /// <summary>
        /// 指定试卷下是否存在同名题型
        /// </summary>
        /// <param name="examId">试卷Id</param>
        /// <param name="txName">题型名称</param>
        bool IsExists(int examId, string txName);

        /// <summary>
        /// 统计题型条数
        /// </summary>
        int Count();

        /// <summary>
        /// 统计指定试卷下的题型条数
        /// </summary>
        /// <param name="examId">试卷Id</param>
        int Count(int examId);
    }
}